<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <meta name="theme-color" content="#34495e">
  <title>码云pages服务搭建hexo个人博客 | 烟波</title>
  <link rel="alternate" href="path/of/rss" type="application/atom+xml">
  <link rel="shortcut icon" type="image/ico" href="/favicon.ico">
  <link rel="stylesheet" href="/my-blog/css/style.css">
  

  

  

  

</head>

<body>
  <div class="mobile-header">
    <span><i class="iconfont icon-turnon" id="mobile-nav-toggle"></i></span>
    <div class="mobile-logo">
      <a href="/my-blog/.">sun</a>
    </div>
  </div>
  <div class="page" id="mobile-nav-panel">
    <div class="container">
      <header class="site-nav">
      <div class="nav-content">
        <div class="logo">
          <a href="/my-blog/">sun</a>
        </div>
        <nav class="navbar">
          <ul>
            
              <li class="menu-item">
                <a href="/my-blog/" class="menu-item-link"><i class="iconfont icon-home"></i>首页</a>
              </li>
            
              <li class="menu-item">
                <a href="/my-blog/archives" class="menu-item-link"><i class="iconfont icon-archive"></i>归档</a>
              </li>
            
          </ul>
        </nav>
      </div>
</header>

      <div class="banner">
  <div class="show">
    <!-- <img src="/my-blog/" alt="banner"> -->
    <div class="banner-title">
      
        <div class="post-title">
          码云pages服务搭建hexo个人博客
            <div class="post-tags">
    		    
              <a class="tag-link" href="/my-blog/tags/hexo/">hexo</a> <a class="tag-link" href="/my-blog/tags/码云pages/">码云pages</a>
            
    	      </div>
        </div>
      
    </div>
  </div>
</div>

      <main class="main"id="main">
          <article class="post">
  

  <header>
    <div class="post-title mobile-post-title">
      <h1>码云pages服务搭建hexo个人博客</h1>
        <div class="post-tags">
        
          <a class="tag-link" href="/my-blog/tags/hexo/">hexo</a> <a class="tag-link" href="/my-blog/tags/码云pages/">码云pages</a>
        
        </div>
    </div>
    <div class="post-meta">
      <span class="post-time"><i class="iconfont icon-calendar"></i>2017-04-15</span>
      
      <!----------------------------------->
        
      <!----------------------------------->
    </div>
  </header>
  
  <div class="post-toc" id="post-toc">
    <h2 class="post-toc-title">目录</h2>
    <div class="post-toc-content">
      <ol class="toc"><li class="toc-item toc-level-2"><a class="toc-link" href="#前提条件："><span class="toc-text">前提条件：</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#1-安装hexo框架"><span class="toc-text">1.安装hexo框架</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#2-搭建hexo"><span class="toc-text">2.搭建hexo</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#3-主题安装"><span class="toc-text">3.主题安装</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#4部署到码云上"><span class="toc-text">4部署到码云上</span></a><ol class="toc-child"><li class="toc-item toc-level-6"><a class="toc-link" href="#每次部署："><span class="toc-text">每次部署：</span></a></li><li class="toc-item toc-level-6"><a class="toc-link" href="#常用命令："><span class="toc-text">常用命令：</span></a></li></ol></li></ol></li></ol></li></ol></li></ol>
    </div>
  </div>


  <div class="post-content">
    <h2 id="前提条件："><a href="#前提条件：" class="headerlink" title="前提条件："></a>前提条件：</h2><p>1.安装node.js<br>2.安装git<br>3.注册码云账号<br>4.使用淘宝镜像npm<br>5.使用vscode编辑器<br><a id="more"></a></p>
<h2 id="1-安装hexo框架"><a href="#1-安装hexo框架" class="headerlink" title="1.安装hexo框架"></a>1.安装hexo框架</h2><p>打开cmd<br><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">cnpm install hexo-cli --globla</span><br></pre></td></tr></table></figure></p>
<p>输入<br><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">hexo version</span><br></pre></td></tr></table></figure></p>
<p>会出现一系列版本信息，说明安装成功！</p>
<h2 id="2-搭建hexo"><a href="#2-搭建hexo" class="headerlink" title="2.搭建hexo"></a>2.搭建hexo</h2><p>在你喜欢的位置新建文件夹，右键文件夹“Open with Code”。<br>在编辑器终端输入<br><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">hexo init</span><br><span class="line">cnpm install hexo --save</span><br></pre></td></tr></table></figure></p>
<p>生成静态文件<br><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">hexo g</span><br></pre></td></tr></table></figure></p>
<p>启动hexo服务<br><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">hexo s</span><br></pre></td></tr></table></figure></p>
<p>到目前为止hexo在本地的启动已经完成。<br>!!!注意如果出现报错，缺少依赖，用 cnpm install 依赖名 安装即可。</p>
<h2 id="3-主题安装"><a href="#3-主题安装" class="headerlink" title="3.主题安装"></a>3.主题安装</h2><p>下载主题包到themes文件下，<br>修改hexo根目录_config.yml文件中theme为下载主题名称。<br>重新生成文件，启动服务。</p>
<h3 id="4部署到码云上"><a href="#4部署到码云上" class="headerlink" title="4部署到码云上"></a>4部署到码云上</h3><p>新建一个项目，复制项目地址<a href="https://gitee.com/syanbo/my-blog.git。" target="_blank" rel="noopener">https://gitee.com/syanbo/my-blog.git。</a><br>配置hexo根目录_config.yml文件：<br><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">deploy:</span><br><span class="line">  type: git</span><br><span class="line">  repo: https://gitee.com/syanbo/my-blog.git</span><br><span class="line">  branch: master</span><br></pre></td></tr></table></figure></p>
<p>然后安装插件：<br><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">cnpm install hexo-deployer-git --save</span><br></pre></td></tr></table></figure></p>
<p>执行命令：<br><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">hexo d</span><br></pre></td></tr></table></figure></p>
<h6 id="每次部署："><a href="#每次部署：" class="headerlink" title="每次部署："></a>每次部署：</h6><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">hexo clean </span><br><span class="line">hexo g</span><br><span class="line">hexo d</span><br></pre></td></tr></table></figure>
<h6 id="常用命令："><a href="#常用命令：" class="headerlink" title="常用命令："></a>常用命令：</h6><p>hexo new”postName” #新建文章<br>hexo generate #生成静态页面至public目录<br>hexo clean #清楚静态页面缓存<br>hexo server #开启预览访问端口（默认端口4000，’ctrl + c’关闭server）<br>hexo deploy #将.deploy目录部署到GitHub<br>hexo help # 查看帮助<br>hexo version #查看Hexo的版本</p>

  </div>
  <div class="post-footer">the end</div>
</article>

          
  <nav class="pagination post-nav">
    
      <a href="/my-blog/2017/05/23/rem适配移动页面-js方法/">
        <span class="prev-post"><i class="iconfont icon-back"></i>rem适配移动页面-js方法</span>
      </a>
    
    
      <a href="/my-blog/2017/04/14/hello-world/">
        <span class="next-post">Hello World<i class="iconfont icon-more"></i></span>
      </a>
    
  </nav>


          
  


      </main>
    </div>
    <footer>
      <div class="social-links">
        
          
            <a href="https://www.zhihu.com/people/qi-lu-kan-fei-ji/activities"><i class="iconfont icon-zhihu"></i></a>
          
        
          
            <a href="https://weibo.com/u/2833609101"><i class="iconfont icon-weibo"></i></a>
          
        
          
            <a href="https://gitee.com/syanbo"><i class="iconfont icon-github"></i></a>
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
      </div>
      
        <div class="quote">
          <p>Love all, trust a few, do wrong to none.——William Shakespeare</p>
        </div>
      
      <div class="copyright">
        <p>
          由 <a href="https://hexo.io/">Hexo</a> 强力驱动
          <span>|</span>
          主题 - <a href="https://github.com/wa-ri/hexo-theme-ztopic">ztopic</a
        </p>
        <p>
          <span>
          
          &copy;
          
            2018
          
          </span>
          <i class="iconfont icon-circle"></i>
          <span>sun</span>
        </p>
      </div>
</footer>

    <div class="back-to-top" id="back-to-top">
      <i class="iconfont icon-up"></i>
    </div>
  </div>
  <div id="mobile-nav">
  <nav id="mobile-nav-menu">
    
      <a href="/my-blog/" class="mobile-nav-link"><i class="iconfont icon-home"></i>首页</a>
    
      <a href="/my-blog/archives" class="mobile-nav-link"><i class="iconfont icon-archive"></i>归档</a>
    
    <div class="mobile-intro"><i class="iconfont icon-pen"></i>practice makes perfect</div>
  </nav>
</div>


  <script src="/my-blog/libs/jQuery/jquery-3.2.1.min.js"></script>
  <script src="/my-blog/libs/slideout/slideout.min.js"></script>
  
    <link rel="stylesheet" href="/my-blog/libs/fancybox/jquery.fancybox.css">
    <script src="/my-blog/libs/fancybox/jquery.fancybox.pack.js"></script>
  
  

  <script src="/my-blog/js/ztopic.js"></script>
</body>
</html>
